
<!DOCTYPE HTML>
<html lang="en" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>认证和授权 · InfluxDB中文文档</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="jasper">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-comment/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../Troubleshooting/" />
    
    
    <link rel="prev" href="math_operators.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://legacy.gitbook.com/book/jasper-zhang1/influxdb" target="_blank" class="custom-link">InfluxDB中文文档</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Introduction/">
            
                <a href="../Introduction/">
            
                    
                    介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Introduction/installation.html">
            
                <a href="../Introduction/installation.html">
            
                    
                    安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../Introduction/getting_start.html">
            
                <a href="../Introduction/getting_start.html">
            
                    
                    入门指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../Guide/">
            
                <a href="../Guide/">
            
                    
                    使用指南
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../Guide/writing_data.html">
            
                <a href="../Guide/writing_data.html">
            
                    
                    写入数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../Guide/querying_data.html">
            
                <a href="../Guide/querying_data.html">
            
                    
                    查询数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../Guide/downsampling_and_retention.html">
            
                <a href="../Guide/downsampling_and_retention.html">
            
                    
                    采样和数据保留
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../Guide/hardware_sizing.html">
            
                <a href="../Guide/hardware_sizing.html">
            
                    
                    硬件指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../Guide/https_setup.html">
            
                <a href="../Guide/https_setup.html">
            
                    
                    HTTPS设置
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../Concepts/">
            
                <a href="../Concepts/">
            
                    
                    概念介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../Concepts/key_concepts.html">
            
                <a href="../Concepts/key_concepts.html">
            
                    
                    关键概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../Concepts/glossary.html">
            
                <a href="../Concepts/glossary.html">
            
                    
                    专业术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../Concepts/crosswalk.html">
            
                <a href="../Concepts/crosswalk.html">
            
                    
                    与SQL比较
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../Concepts/insights_tradeoffs.html">
            
                <a href="../Concepts/insights_tradeoffs.html">
            
                    
                    InfluxDB的设计见解和权衡
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../Concepts/schema_and_data_layout.html">
            
                <a href="../Concepts/schema_and_data_layout.html">
            
                    
                    schema设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../Concepts/storage_engine.html">
            
                <a href="../Concepts/storage_engine.html">
            
                    
                    存储引擎
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Write_protocols/">
            
                <a href="../Write_protocols/">
            
                    
                    写入协议
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Write_protocols/line_protocol.html">
            
                <a href="../Write_protocols/line_protocol.html">
            
                    
                    行协议
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="./">
            
                <a href="./">
            
                    
                    查询语言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="data_exploration.html">
            
                <a href="data_exploration.html">
            
                    
                    数据查询语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="schema_exploration.html">
            
                <a href="schema_exploration.html">
            
                    
                    schema查询语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="database_management.html">
            
                <a href="database_management.html">
            
                    
                    数据库管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="continuous_queries.html">
            
                <a href="continuous_queries.html">
            
                    
                    连续查询
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="functions.html">
            
                <a href="functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="math_operators.html">
            
                <a href="math_operators.html">
            
                    
                    数学运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6.7" data-path="authentication_and_authorization.html">
            
                <a href="authentication_and_authorization.html">
            
                    
                    认证和授权
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../Troubleshooting/">
            
                <a href="../Troubleshooting/">
            
                    
                    故障排除
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../Troubleshooting/faq.html">
            
                <a href="../Troubleshooting/faq.html">
            
                    
                    FAQ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../Troubleshooting/system_monitor.html">
            
                <a href="../Troubleshooting/system_monitor.html">
            
                    
                    系统监控
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../Troubleshooting/query_management.html">
            
                <a href="../Troubleshooting/query_management.html">
            
                    
                    查询管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../Troubleshooting/error_messages.html">
            
                <a href="../Troubleshooting/error_messages.html">
            
                    
                    错误信息
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >认证和授权</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x8BA4;&#x8BC1;&#x548C;&#x6388;&#x6743;">&#x8BA4;&#x8BC1;&#x548C;&#x6388;&#x6743;</h1>
<h2 id="&#x8BA4;&#x8BC1;">&#x8BA4;&#x8BC1;</h2>
<p>InfluxDB&#x7684;HTTP API&#x548C;&#x547D;&#x4EE4;&#x884C;&#x754C;&#x9762;&#xFF08;CLI&#xFF09;&#xFF0C;&#x5305;&#x62EC;&#x7B80;&#x5355;&#x7684;&#x57FA;&#x4E8E;&#x7528;&#x6237;&#x51ED;&#x636E;&#x7684;&#x5185;&#x7F6E;&#x8BA4;&#x8BC1;&#x3002;&#x5F53;&#x5F00;&#x542F;&#x8BA4;&#x8BC1;&#x65F6;&#xFF0C;InfluxDB&#x53EA;&#x4F1A;&#x6267;&#x884C;&#x53D1;&#x9001;&#x4E2D;&#x5E26;&#x6709;&#x6709;&#x6548;&#x8BC1;&#x4E66;&#x7684;HTTP&#x8BF7;&#x6C42;&#x3002;</p>
<blockquote>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x8BA4;&#x8BC1;&#x53EA;&#x53D1;&#x751F;&#x5728;HTTP&#x8BF7;&#x6C42;&#x8303;&#x56F4;&#x5185;&#x3002;&#x63D2;&#x4EF6;&#x76EE;&#x524D;&#x4E0D;&#x5177;&#x5907;&#x8BA4;&#x8BC1;&#x8BF7;&#x6C42;&#x7684;&#x80FD;&#x529B;&#xFF0C;&#xFF08;&#x4F8B;&#x5982;Graphite&#x3001;collectd&#x7B49;&#xFF09;&#x662F;&#x6CA1;&#x6709;&#x8BA4;&#x8BC1;&#x7684;&#x3002;</p>
</blockquote>
<h3 id="&#x521B;&#x5EFA;&#x8BA4;&#x8BC1;">&#x521B;&#x5EFA;&#x8BA4;&#x8BC1;</h3>
<h4 id="1-&#x81F3;&#x5C11;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;admin&#x7528;&#x6237;">1. &#x81F3;&#x5C11;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;admin&#x7528;&#x6237;</h4>
<blockquote>
<p>&#x5982;&#x679C;&#x4F60;&#x5F00;&#x542F;&#x4E86;&#x8BA4;&#x8BC1;&#x4F46;&#x662F;&#x6CA1;&#x6709;&#x7528;&#x6237;&#xFF0C;&#x90A3;&#x4E48;InfluxDB&#x5C06;&#x4E0D;&#x4F1A;&#x5F00;&#x542F;&#x8BA4;&#x8BC1;&#xFF0C;&#x800C;&#x4E14;&#x53EA;&#x6709;&#x5728;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;admin&#x7528;&#x6237;&#x4E4B;&#x540E;&#x624D;&#x4F1A;&#x63A5;&#x53D7;&#x5916;&#x90E8;&#x8BF7;&#x6C42;&#x3002;</p>
</blockquote>
<p>&#x5F53;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;admin&#x7528;&#x6237;&#x540E;&#xFF0C;InfluxDB&#x624D;&#x80FD;&#x5F00;&#x542F;&#x8BA4;&#x8BC1;&#x3002;</p>
<h4 id="2-&#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x8BA4;&#x8BC1;&#x9ED8;&#x8BA4;&#x662F;&#x4E0D;&#x5F00;&#x542F;&#x7684;">2. &#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x8BA4;&#x8BC1;&#x9ED8;&#x8BA4;&#x662F;&#x4E0D;&#x5F00;&#x542F;&#x7684;</h4>
<p>&#x5C06;<code>[http]</code>&#x533A;&#x57DF;&#x7684;&#x914D;&#x7F6E;<code>auth-enabled</code>&#x8BBE;&#x4E3A;<code>true</code>&#xFF0C;&#x53EF;&#x4EE5;&#x5F00;&#x542F;&#x8BA4;&#x8BC1;&#xFF1A;</p>
<pre><code>[http]  
  enabled = true  
  bind-address = &quot;:8086&quot;  
  auth-enabled = true # &#x2728;
  log-enabled = true  
  write-tracing = false  
  pprof-enabled = false  
  https-enabled = false  
  https-certificate = &quot;/etc/ssl/influxdb.pem&quot;
</code></pre><h4 id="3-&#x91CD;&#x542F;&#x8FDB;&#x7A0B;">3. &#x91CD;&#x542F;&#x8FDB;&#x7A0B;</h4>
<p>&#x73B0;&#x5728;InfluxDB&#x4F1A;&#x6838;&#x5BF9;&#x6BCF;&#x4E2A;&#x8BF7;&#x6C42;&#x4E2D;&#x7684;&#x7528;&#x6237;&#x4FE1;&#x606F;&#xFF0C;&#x53EA;&#x4F1A;&#x5904;&#x7406;&#x5DF2;&#x6709;&#x7528;&#x6237;&#x800C;&#x8BA4;&#x8BC1;&#x901A;&#x8FC7;&#x7684;&#x8BF7;&#x6C42;&#x3002;</p>
<h3 id="&#x8BA4;&#x8BC1;&#x8BF7;&#x6C42;">&#x8BA4;&#x8BC1;&#x8BF7;&#x6C42;</h3>
<h4 id="http-api&#x4E2D;&#x7684;&#x8BA4;&#x8BC1;">HTTP API&#x4E2D;&#x7684;&#x8BA4;&#x8BC1;</h4>
<p>&#x6709;&#x4E24;&#x4E2A;HTTP API&#x8FDB;&#x884C;&#x9A8C;&#x8BC1;&#x7684;&#x65B9;&#x5F0F;&#x3002;</p>
<p>&#x5982;&#x679C;&#x4F7F;&#x7528;&#x57FA;&#x672C;&#x8EAB;&#x4EFD;&#x9A8C;&#x8BC1;&#x548C;URL&#x67E5;&#x8BE2;&#x53C2;&#x6570;&#x8FDB;&#x884C;&#x8EAB;&#x4EFD;&#x9A8C;&#x8BC1;&#xFF0C;&#x5219;&#x4EE5;&#x67E5;&#x8BE2;&#x53C2;&#x6570;&#x4E2D;&#x6307;&#x5B9A;&#x7684;&#x7528;&#x6237;&#x4F18;&#x5148;&#x3002;&#x4E0B;&#x9762;&#x7684;&#x793A;&#x4F8B;&#x4E2D;&#x7684;&#x67E5;&#x8BE2;&#x5047;&#x5B9A;&#x7528;&#x6237;&#x662F;admin&#x7528;&#x6237;&#x3002;</p>
<h5 id="&#x7528;rfc-2617&#x4E2D;&#x6240;&#x63CF;&#x8FF0;&#x7684;&#x57FA;&#x672C;&#x8EAB;&#x4EFD;&#x9A8C;&#x8BC1;">&#x7528;<a href="http://tools.ietf.org/html/rfc2617" target="_blank">RFC 2617</a>&#x4E2D;&#x6240;&#x63CF;&#x8FF0;&#x7684;&#x57FA;&#x672C;&#x8EAB;&#x4EFD;&#x9A8C;&#x8BC1;</h5>
<p>&#x8FD9;&#x662F;&#x63D0;&#x4F9B;&#x7528;&#x6237;&#x7684;&#x9996;&#x9009;&#x65B9;&#x6CD5;&#x3002;&#x4F8B;:</p>
<pre><code>curl -G http://localhost:8086/query -u todd:influxdb4ever --data-urlencode &quot;q=SHOW DATABASES&quot;
</code></pre><h5 id="&#x5728;url&#x7684;&#x53C2;&#x6570;&#x6216;&#x662F;&#x8BF7;&#x6C42;&#x4F53;&#x91CC;&#x9762;&#x63D0;&#x4F9B;&#x8BA4;&#x8BC1;">&#x5728;URL&#x7684;&#x53C2;&#x6570;&#x6216;&#x662F;&#x8BF7;&#x6C42;&#x4F53;&#x91CC;&#x9762;&#x63D0;&#x4F9B;&#x8BA4;&#x8BC1;</h5>
<p>&#x8BBE;&#x7F6E;<code>u</code>&#x548C;<code>p</code>&#x53C2;&#x6570;&#xFF0C; &#x4F8B;&#xFF1A;</p>
<pre><code>curl -G &quot;http://localhost:8086/query?u=todd&amp;p=influxdb4ever&quot; --data-urlencode &quot;q=SHOW DATABASES&quot;
</code></pre><p>&#x8BA4;&#x8BC1;&#x5728;&#x8BF7;&#x6C42;&#x4F53;&#x4E2D;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>curl -G http://localhost:8086/query --data-urlencode &quot;u=todd&quot; --data-urlencode &quot;p=influxdb4ever&quot; --data-urlencode &quot;q=SHOW DATABASES&quot;
</code></pre><h4 id="cli&#x4E2D;&#x7684;&#x8BA4;&#x8BC1;">CLI&#x4E2D;&#x7684;&#x8BA4;&#x8BC1;</h4>
<p>&#x5728;CLI&#x4E2D;&#x6709;&#x4E09;&#x79CD;&#x8BA4;&#x8BC1;&#x65B9;&#x5F0F;&#x3002;</p>
<h5 id="&#x8BBE;&#x7F6E;influxusername&#x548C;influxpassword&#x73AF;&#x5883;&#x53D8;&#x91CF;">&#x8BBE;&#x7F6E;<code>INFLUX_USERNAME</code>&#x548C;<code>INFLUX_PASSWORD</code>&#x73AF;&#x5883;&#x53D8;&#x91CF;</h5>
<p>&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>export INFLUX_USERNAME todd
export INFLUX_PASSWORD influxdb4ever
echo $INFLUX_USERNAME $INFLUX_PASSWORD
todd influxdb4ever

influx
Connected to http://localhost:8086 version 1.3.x
InfluxDB shell 1.3.x
</code></pre><h5 id="&#x5F00;&#x542F;cli&#x65F6;&#x8BBE;&#x7F6E;username&#x548C;password">&#x5F00;&#x542F;CLI&#x65F6;&#x8BBE;&#x7F6E;<code>username</code>&#x548C;<code>password</code></h5>
<p>&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>influx -username todd -password influxdb4ever
Connected to http://localhost:8086 version 1.3.x
InfluxDB shell 1.3.x
</code></pre><h5 id="&#x5F00;&#x542F;cli&#x540E;&#x4F7F;&#x7528;auth-username-password">&#x5F00;&#x542F;CLI&#x540E;&#x4F7F;&#x7528;<code>auth &lt;username&gt; &lt;password&gt;</code></h5>
<p>&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>influx
Connected to http://localhost:8086 version 1.3.x
InfluxDB shell 1.3.x
&gt; auth
username: todd
password:
&gt;
</code></pre><h2 id="&#x6388;&#x6743;">&#x6388;&#x6743;</h2>
<p>&#x5F53;&#x5F00;&#x542F;&#x8BA4;&#x8BC1;&#x4E4B;&#x540E;&#xFF0C;&#x6388;&#x6743;&#x4E5F;&#x5C31;&#x5F00;&#x542F;&#x4E86;&#x3002;&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x7528;&#x6237;&#x90FD;&#x6709;&#x6240;&#x6709;&#x7684;&#x6743;&#x9650;&#x3002;</p>
<h3 id="&#x7528;&#x6237;&#x7C7B;&#x578B;&#x548C;&#x6743;&#x9650;">&#x7528;&#x6237;&#x7C7B;&#x578B;&#x548C;&#x6743;&#x9650;</h3>
<h4 id="admin&#x7528;&#x6237;">admin&#x7528;&#x6237;</h4>
<p>admin&#x7528;&#x6237;&#x6709;&#x6240;&#x6709;&#x6570;&#x636E;&#x5E93;&#x7684;&#x8BFB;&#x5199;&#x6743;&#x9650;&#xFF0C;&#x8FD9;&#x4E9B;&#x6240;&#x6709;&#x7684;&#x6743;&#x9650;&#x5305;&#x62EC;&#x5982;&#x4E0B;&#xFF1A;</p>
<p>&#x6570;&#x636E;&#x5E93;&#x7BA1;&#x7406;&#xFF1A;</p>
<ul>
<li><code>CREATE DATABASE</code>, <code>DROP DATABASE</code></li>
<li><code>DROP SERIES</code>, <code>DROP MEASUREMENT</code></li>
<li><code>CREATE RETENTION POLICY</code>,<code>ALTER RETENTION POLICY</code>, &#x548C; <code>DROP RETENTION POLICY</code></li>
<li><code>CREATE CONTINUOUS QUERY</code>&#x548C;<code>DROP CONTINUOUS QUERY</code></li>
</ul>
<p>&#x7528;&#x6237;&#x7BA1;&#x7406;&#xFF1A;</p>
<ul>
<li><p>admin&#x7528;&#x6237;&#x7BA1;&#x7406;&#xFF1A;<br><code>CREATE USER</code>, <code>GRANT ALL PRIVILEGES</code>, <code>REVOKE ALL PRIVILEGES</code>,&#x548C;<code>SHOW USERS</code></p>
</li>
<li><p>&#x975E;admin&#x7528;&#x6237;&#x7BA1;&#x7406;&#xFF1A;<br><code>CREATE USER</code>, <code>GRANT [READ,WRITE,ALL]</code>, <code>REVOKE [READ,WRITE,ALL]</code>,&#x548C;<code>SHOW GRANTS</code></p>
</li>
<li><p>&#x4E00;&#x822C;admin&#x7528;&#x6237;&#x7BA1;&#x7406;&#xFF1A;<br><code>SET PASSWORD</code>&#x548C;<code>DROP USER</code></p>
</li>
</ul>
<h4 id="&#x975E;admin&#x7528;&#x6237;">&#x975E;admin&#x7528;&#x6237;</h4>
<p>&#x975E;admin&#x7528;&#x6237;&#x5BF9;&#x4E8E;&#x6BCF;&#x4E2A;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x6709;&#x5982;&#x4E0B;&#x4E09;&#x4E2A;&#x6743;&#x9650;&#xFF1A;</p>
<ul>
<li><code>READ</code></li>
<li><code>WRITE</code></li>
<li><code>ALL</code>&#xFF08;&#x5305;&#x62EC;<code>READ</code>&#x548C;<code>WRITE</code>&#xFF09;</li>
</ul>
<p><code>READ</code>,<code>WRITE</code>&#x548C;<code>ALL</code>&#x63A7;&#x5236;&#x5230;&#x6BCF;&#x4E2A;&#x6570;&#x636E;&#x5E93;&#x6BCF;&#x4E2A;&#x7528;&#x6237;&#x4E0A;&#x3002;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x975E;admin&#x7528;&#x6237;&#x5BF9;&#x4EFB;&#x4F55;&#x6570;&#x636E;&#x5E93;&#x90FD;&#x6CA1;&#x6709;&#x6743;&#x9650;&#xFF0C;&#x9664;&#x975E;&#x88AB;admin&#x7528;&#x6237;&#x6307;&#x5B9A;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x5E93;&#x6743;&#x9650;&#x3002;&#x975E;admin&#x7528;&#x6237;&#x53EF;&#x4EE5;&#x5728;&#x4ED6;&#x4EEC;&#x6709;<code>READ</code>&#x6216;/&#x548C;<code>WRITE</code>&#x6743;&#x9650;&#x7684;&#x673A;&#x5668;&#x4E0A;&#x8FD0;&#x884C;<code>SHOW</code>&#x547D;&#x4EE4;&#x3002;</p>
<h3 id="&#x7528;&#x6237;&#x7BA1;&#x7406;&#x547D;&#x4EE4;">&#x7528;&#x6237;&#x7BA1;&#x7406;&#x547D;&#x4EE4;</h3>
<h4 id="admin&#x7528;&#x6237;&#x7BA1;&#x7406;">admin&#x7528;&#x6237;&#x7BA1;&#x7406;</h4>
<p>&#x5F53;&#x5F00;&#x542F;HTTP&#x8BA4;&#x8BC1;&#x4E4B;&#x540E;&#xFF0C;&#x5728;&#x4F60;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x4E4B;&#x524D;&#xFF0C;InfluxDB&#x8981;&#x6C42;&#x4F60;&#x81F3;&#x5C11;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;admin&#x7528;&#x6237;&#x3002;</p>
<pre><code>CREATE USER admin WITH PASSWORD &apos;&lt;password&gt;&apos; WITH ALL PRIVILEGES
</code></pre><h5 id="create&#x53E6;&#x4E00;&#x4E2A;admin&#x7528;&#x6237;"><code>CREATE</code>&#x53E6;&#x4E00;&#x4E2A;admin&#x7528;&#x6237;</h5>
<pre><code>CREATE USER &lt;username&gt; WITH PASSWORD &apos;&lt;password&gt;&apos; WITH ALL PRIVILEGES
</code></pre><p>CLI&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>&gt; CREATE USER paul WITH PASSWORD &apos;timeseries4days&apos; WITH ALL PRIVILEGES
&gt;
</code></pre><blockquote>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x91CD;&#x590D;&#x521B;&#x5EFA;&#x786E;&#x5207;&#x7684;&#x7528;&#x6237;&#x8BED;&#x53E5;&#x662F;&#x5E42;&#x7B49;&#x7684;&#x3002;&#x5982;&#x679C;&#x6709;&#x503C;&#x53D1;&#x751F;&#x53D8;&#x5316;&#xFF0C;&#x6570;&#x636E;&#x5E93;&#x5C06;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x91CD;&#x590D;&#x7684;&#x7528;&#x6237;&#x9519;&#x8BEF;&#x3002;
CLI&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>CREATE USER todd WITH PASSWORD &apos;123456&apos; WITH ALL PRIVILEGES
CREATE USER todd WITH PASSWORD &apos;123456&apos; WITH ALL PRIVILEGES
CREATE USER todd WITH PASSWORD &apos;123&apos; WITH ALL PRIVILEGES
ERR: user already exists
CREATE USER todd WITH PASSWORD &apos;123456&apos;
ERR: user already exists
CREATE USER todd WITH PASSWORD &apos;123456&apos; WITH ALL PRIVILEGES
</code></pre></blockquote>
<h5 id="&#x7ED9;&#x4E00;&#x4E2A;&#x5B58;&#x5728;&#x7684;&#x7528;&#x6237;grant&#x6743;&#x9650;">&#x7ED9;&#x4E00;&#x4E2A;&#x5B58;&#x5728;&#x7684;&#x7528;&#x6237;<code>GRANT</code>&#x6743;&#x9650;</h5>
<pre><code>GRANT ALL PRIVILEGES TO &lt;username&gt;
</code></pre><p>CLI&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>&gt; GRANT ALL PRIVILEGES TO &quot;todd&quot;
&gt;
</code></pre><h5 id="&#x7ED9;&#x4E00;&#x4E2A;admin&#x7528;&#x6237;revoke&#x6743;&#x9650;">&#x7ED9;&#x4E00;&#x4E2A;admin&#x7528;&#x6237;<code>REVOKE</code>&#x6743;&#x9650;</h5>
<pre><code>REVOKE ALL PRIVILEGES FROM &lt;username&gt;
</code></pre><p>CLI&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>&gt; REVOKE ALL PRIVILEGES FROM &quot;todd&quot;
&gt;
</code></pre><h5 id="show&#x6240;&#x6709;&#x5B58;&#x5728;&#x7684;&#x7528;&#x6237;&#x4EE5;&#x53CA;&#x5176;admin&#x72B6;&#x6001;"><code>SHOW</code>&#x6240;&#x6709;&#x5B58;&#x5728;&#x7684;&#x7528;&#x6237;&#x4EE5;&#x53CA;&#x5176;admin&#x72B6;&#x6001;</h5>
<pre><code>SHOW USERS
</code></pre><p>CLI&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>&gt; SHOW USERS
user      admin
todd     false
paul     true
hermione false
dobby    false
</code></pre><h4 id="&#x975E;admin&#x7528;&#x6237;&#x7BA1;&#x7406;">&#x975E;admin&#x7528;&#x6237;&#x7BA1;&#x7406;</h4>
<h5 id="create&#x4E00;&#x4E2A;&#x975E;admin&#x7528;&#x6237;&#xFF1A;"><code>CREATE</code>&#x4E00;&#x4E2A;&#x975E;admin&#x7528;&#x6237;&#xFF1A;</h5>
<pre><code>CREATE USER &lt;username&gt; WITH PASSWORD &apos;&lt;password&gt;&apos;
</code></pre><p>CLI&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>&gt; CREATE USER todd WITH PASSWORD &apos;influxdb41yf3&apos;
&gt; CREATE USER alice WITH PASSWORD &apos;wonder\&apos;land&apos;
&gt; CREATE USER &quot;rachel_smith&quot; WITH PASSWORD &apos;asdf1234!&apos;
&gt; CREATE USER &quot;monitoring-robot&quot; WITH PASSWORD &apos;XXXXX&apos;
&gt; CREATE USER &quot;$savyadmin&quot; WITH PASSWORD &apos;m3tr1cL0v3r&apos;
&gt;
</code></pre><blockquote>
<p>&#x6CE8;&#x610F;&#xFF1A;</p>
<ul>
<li>&#x7528;&#x6237;&#x540D;&#x5982;&#x679C;&#x7528;&#x4E00;&#x4E2A;&#x6570;&#x5B57;&#x7684;&#x5F00;&#x59CB;&#xFF0C;&#x6216;&#x8005;&#x662F;&#x4E00;&#x4E2A;influxql&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x53C8;&#x6216;&#x8005;&#x5305;&#x542B;&#x4EFB;&#x4F55;&#x7279;&#x6B8A;&#x5B57;&#x7B26;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;<code>!@#$%^&amp;*()-</code>, &#x5219;&#x5FC5;&#x987B;&#x7528;&#x53CC;&#x5F15;&#x53F7;&#x5F15;&#x8D77;&#x6765;</li>
<li>&#x5BC6;&#x7801;&#x5B57;&#x7B26;&#x4E32;&#x5FC5;&#x987B;&#x7528;&#x5355;&#x5F15;&#x53F7;&#x5F15;&#x8D77;&#x6765;&#x3002;</li>
<li>&#x5728;&#x9A8C;&#x8BC1;&#x8BF7;&#x6C42;&#x65F6;&#x4E0D;&#x5305;&#x542B;&#x5355;&#x5F15;&#x53F7;&#x3002;</li>
</ul>
<p>&#x5982;&#x679C;&#x5BC6;&#x7801;&#x5305;&#x542B;&#x5355;&#x5F15;&#x53F7;&#x6216;&#x6362;&#x884C;&#x7B26;&#xFF0C;&#x5F53;&#x63D0;&#x4EA4;&#x8BA4;&#x8BC1;&#x8BF7;&#x6C42;&#x65F6;&#xFF0C;&#x5E94;&#x8BE5;&#x7528;&#x53CD;&#x659C;&#x6760;&#x8F6C;&#x4E49;&#x3002;</p>
</blockquote>
<h5 id="grant-read-write&#x6216;&#x8005;all&#x6570;&#x636E;&#x5E93;&#x6743;&#x9650;&#x7ED9;&#x4E00;&#x4E2A;&#x5B58;&#x5728;&#x7684;&#x7528;&#x6237;"><code>GRANT READ, WRITE</code>&#x6216;&#x8005;<code>ALL</code>&#x6570;&#x636E;&#x5E93;&#x6743;&#x9650;&#x7ED9;&#x4E00;&#x4E2A;&#x5B58;&#x5728;&#x7684;&#x7528;&#x6237;</h5>
<pre><code>GRANT [READ,WRITE,ALL] ON &lt;database_name&gt; TO &lt;username&gt;
</code></pre><p>CLI&#x4F8B;&#x5B50;&#xFF1A; &#x7ED9;&#x7528;&#x6237;<code>todd``GRANT</code>&#x6570;&#x636E;&#x5E93;<code>NOAA_water_database</code>&#x7684;<code>READ</code>&#x7684;&#x6743;&#x9650;&#xFF1A;</p>
<pre><code>&gt; GRANT READ ON &quot;NOAA_water_database&quot; TO &quot;todd&quot;
&gt;
</code></pre><p>&#x7ED9;&#x7528;&#x6237;<code>todd``GRANT</code>&#x6570;&#x636E;&#x5E93;<code>NOAA_water_database</code>&#x7684;<code>ALL</code>&#x7684;&#x6743;&#x9650;&#xFF1A;</p>
<pre><code>&gt; GRANT ALL ON &quot;NOAA_water_database&quot; TO &quot;todd&quot;
&gt;
</code></pre><h5 id="revoke-read-write&#x6216;&#x8005;all-&#x6570;&#x636E;&#x5E93;&#x6743;&#x9650;&#x7ED9;&#x4E00;&#x4E2A;&#x5B58;&#x5728;&#x7684;&#x7528;&#x6237;"><code>REVOKE READ, WRITE</code>&#x6216;&#x8005;<code>ALL</code> &#x6570;&#x636E;&#x5E93;&#x6743;&#x9650;&#x7ED9;&#x4E00;&#x4E2A;&#x5B58;&#x5728;&#x7684;&#x7528;&#x6237;</h5>
<pre><code>REVOKE [READ,WRITE,ALL] ON &lt;database_name&gt; FROM &lt;username&gt;
</code></pre><p>CLI&#x4F8B;&#x5B50;&#xFF1A; &#x7ED9;&#x7528;&#x6237;<code>todd``REVOKE</code>&#x6570;&#x636E;&#x5E93;<code>NOAA_water_database</code>&#x7684;<code>ALL</code>&#x7684;&#x6743;&#x9650;&#xFF1A;</p>
<pre><code>&gt; REVOKE ALL ON &quot;NOAA_water_database&quot; FROM &quot;todd&quot;
&gt;
</code></pre><p>&#x7ED9;&#x7528;&#x6237;<code>todd``REVOKE</code>&#x6570;&#x636E;&#x5E93;<code>NOAA_water_database</code>&#x7684;<code>WRITE</code>&#x7684;&#x6743;&#x9650;&#xFF1A;</p>
<pre><code>&gt; REVOKE WRITE ON &quot;NOAA_water_database&quot; FROM &quot;todd&quot;
&gt;
</code></pre><h5 id="show&#x4E00;&#x4E2A;&#x7528;&#x6237;&#x7684;&#x6570;&#x636E;&#x5E93;&#x6743;&#x9650;"><code>SHOW</code>&#x4E00;&#x4E2A;&#x7528;&#x6237;&#x7684;&#x6570;&#x636E;&#x5E93;&#x6743;&#x9650;</h5>
<pre><code>SHOW GRANTS FOR &lt;user_name&gt;
</code></pre><p>CLI&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>&gt; SHOW GRANTS FOR &quot;todd&quot;
database                    privilege
NOAA_water_database            WRITE
another_database_name        READ
yet_another_database_name   ALL PRIVILEGES
</code></pre><h4 id="&#x666E;&#x901A;admin&#x548C;&#x975E;admin&#x7528;&#x6237;&#x7BA1;&#x7406;">&#x666E;&#x901A;admin&#x548C;&#x975E;admin&#x7528;&#x6237;&#x7BA1;&#x7406;</h4>
<h5 id="&#x91CD;&#x65B0;&#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x7528;&#x6237;&#x7684;&#x5BC6;&#x7801;">&#x91CD;&#x65B0;&#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x7528;&#x6237;&#x7684;&#x5BC6;&#x7801;</h5>
<pre><code>SET PASSWORD FOR &lt;username&gt; = &apos;&lt;password&gt;&apos;
</code></pre><p>CLI&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>&gt; SET PASSWORD FOR &quot;todd&quot; = &apos;influxdb4ever&apos;
&gt;
</code></pre><pre><code>&gt; **Note:** The password [string](/influxdb/v1.3/query_language/spec/#strings) must be wrapped in single quotes.
</code></pre><h5 id="drop&#x4E00;&#x4E2A;&#x7528;&#x6237;"><code>DROP</code>&#x4E00;&#x4E2A;&#x7528;&#x6237;</h5>
<pre><code>DROP USER &lt;username&gt;
</code></pre><p>CLI&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>&gt; DROP USER &quot;todd&quot;
&gt;
</code></pre><h2 id="&#x8BA4;&#x8BC1;&#x548C;&#x6388;&#x6743;&#x7684;http&#x9519;&#x8BEF;">&#x8BA4;&#x8BC1;&#x548C;&#x6388;&#x6743;&#x7684;HTTP&#x9519;&#x8BEF;</h2>
<p>&#x6CA1;&#x6709;&#x8BA4;&#x8BC1;&#x6216;&#x8005;&#x662F;&#x5E26;&#x6709;&#x4E0D;&#x6B63;&#x786E;&#x8BA4;&#x8BC1;&#x4FE1;&#x606F;&#x7684;&#x8BF7;&#x6C42;&#x53D1;&#x5230;InfluxDB&#xFF0C;&#x5C06;&#x4F1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;<code>HTTP 401 Unauthorized</code>&#x7684;&#x9519;&#x8BEF;&#x3002;</p>
<p>&#x6CA1;&#x6709;&#x6388;&#x6743;&#x7684;&#x7528;&#x6237;&#x7684;&#x8BF7;&#x6C42;&#x53D1;&#x5230;InfluxDB&#xFF0C;&#x5C06;&#x4F1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;<code>HTTP 403 Forbidden</code>&#x7684;&#x9519;&#x8BEF;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="math_operators.html" class="navigation navigation-prev " aria-label="Previous page: 数学运算符">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../Troubleshooting/" class="navigation navigation-next " aria-label="Next page: 故障排除">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"认证和授权","level":"1.6.7","depth":2,"next":{"title":"故障排除","level":"1.7","depth":1,"path":"Troubleshooting/index.md","ref":"Troubleshooting/index.md","articles":[{"title":"FAQ","level":"1.7.1","depth":2,"path":"Troubleshooting/faq.md","ref":"Troubleshooting/faq.md","articles":[]},{"title":"系统监控","level":"1.7.2","depth":2,"path":"Troubleshooting/system_monitor.md","ref":"Troubleshooting/system_monitor.md","articles":[]},{"title":"查询管理","level":"1.7.3","depth":2,"path":"Troubleshooting/query_management.md","ref":"Troubleshooting/query_management.md","articles":[]},{"title":"错误信息","level":"1.7.4","depth":2,"path":"Troubleshooting/error_messages.md","ref":"Troubleshooting/error_messages.md","articles":[]}]},"previous":{"title":"数学运算符","level":"1.6.6","depth":2,"path":"Query_language/math_operators.md","ref":"Query_language/math_operators.md","articles":[]},"dir":"ltr"},"config":{"plugins":["comment"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"comment":{"highlightCommented":true},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"github":"jasper-zhang/influxdb-document-cn","theme":"default","author":"jasper","pdf":{"pageNumbers":true,"fontSize":16,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"InfluxDB中文文档","language":"en","links":{"sidebar":{"InfluxDB中文文档":"https://legacy.gitbook.com/book/jasper-zhang1/influxdb"},"gitbook":true},"gitbook":"*","description":""},"file":{"path":"Query_language/authentication_and_authorization.md","mtime":"2019-09-29T09:05:38.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-09-29T09:10:37.143Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-comment/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

